import { defineStore } from 'pinia';
import { saveStorage } from '../utils/storage';
import * as toolStorage from '../utils/tools';

const useMenu = defineStore('menu', {
  state: () => ({
    // 是否显示 授课资源 悬浮功能
    resourcePanel: false,
    // 记录从什么地方进入的授课工具
    // bar: 从侧边栏进入
    // resource: 从资源进入
    inType: '',
    // 存储资源
    courseData: JSON.parse(toolStorage.getStorage('resourceList') || '[]'),
  }),
  actions: {
    setSlideRPanel(boo) {
      this.resourcePanel = boo;
    },
    setInType(t) {
      saveStorage('newDrawType', t);
      this.inType = t;
    },
    setCourseData(data) {
      toolStorage.saveStorage('resourceList', JSON.stringify(data));
      this.courseData = data;
    },
  },
});
export default useMenu;
